package com.example.controller.User;

import com.example.pojo.VO.Result;
import com.example.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/message")
public class MessageController {

    @Autowired
    private MessageService messageService;


//    TODO 后期更改增加商品id和店铺id
    @PostMapping("/addMessage")
    public Result addMessage(String test,String product_id)
    {
        log.info("发布消息{}",test);
        return messageService.sendMessage(test,product_id);
    }

    @DeleteMapping("/deleteMessage")
    public Result deleteMessage( String id)
    {
        log.info("删除留言{}",id);
        return messageService.deleteMessage(id);
    }

//  TODO  根据不同的是商品拿到不同的留言信息,传入商品id
    @GetMapping("/getMessage")
    public Result getMessage()
    {
        log.info("获取留言信息");
        return messageService.getMessages();
    }
}
